package app.cloudstringers;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

public class MyVideoTab extends TabActivity {
	private static TabHost tabHost;
	public static int CURRENT_TAB = 0;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		tabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;

		// Separate intents
		// new intent to All class, All collection
		intent = new Intent(this, All.class);

		spec = tabHost.newTabSpec(getString(R.string.all));
		spec.setIndicator(getString(R.string.all),
				getResources().getDrawable(R.drawable.ic_all_normal)).setContent(intent);
		tabHost.addTab(spec);

		// new intent to All class, Auction collection
		spec = tabHost.newTabSpec(getString(R.string.auction));
		spec.setIndicator(getString(R.string.auction),
				getResources().getDrawable(R.drawable.ic_auction_normal)).setContent(
				intent);
		tabHost.addTab(spec);

		// new intent to All class, Market place collection
		spec = tabHost.newTabSpec(getString(R.string.market_place));
		spec.setIndicator(getString(R.string.market_place),
				getResources().getDrawable(R.drawable.ic_market_place_normal))
				.setContent(intent);
		tabHost.addTab(spec);

		// new intent to All class, privacy collection
		spec = tabHost.newTabSpec(getString(R.string.privacy));
		spec.setIndicator(getString(R.string.privacy),
				getResources().getDrawable(R.drawable.ic_private_normal))
				.setContent(intent);
		tabHost.addTab(spec);

		// Set current tab to transfer firstly
		tabHost.setCurrentTab(CURRENT_TAB);

		// TODO Might be change to the tab changed
		tabHost.setOnTabChangedListener(new OnTabChangeListener() {

			@Override
			public void onTabChanged(String arg0) {
				CURRENT_TAB = tabHost.getCurrentTab();

				// Call new thread for refresh tab
				// Refresh upload tab continuously to see new items
				// if (Constants.connectivity.isNetworkOnline()) {
				// new AllTabsAsync(All.mContextAll)
				// .execute(MyVideoTab.CURRENT_TAB);

				// new GetTokenString(All.mContextAll, true).execute();
				// }
			}
		});
	}
}
